package com.example.canteen.controller;
import com.example.canteen.domain.Suppliers;
import com.example.canteen.domain.User;
import com.example.canteen.service.SuppliersService;
import com.example.canteen.service.UserService;
import com.example.canteen.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

@RequestMapping("/suppliers")
@Api(tags = "供应商管理(0304 高凯)")
//@Anonymous
public class SuppliersController {
    @Autowired
    SuppliersService service;
    @GetMapping("/getSuppliersListAll")
    @ApiOperation(value = "获取所有供应商列表")
    public AjaxResult getSuppliersListAll() {
        System.out.println(service.selectAllSuppliers());
        return AjaxResult.success(service.selectAllSuppliers());
    };
    @GetMapping("/getSuppliersById/{supplierID}")
    @ApiOperation(value = "根据id查询供应商信息")
    public AjaxResult getSuppliersById(@PathVariable int supplierID) {
        System.out.println(service.selectSuppliersById(supplierID));
        return AjaxResult.success(service.selectSuppliersById(supplierID));
    }
    @PostMapping("/insertSuppliers")
    @ApiOperation(value = "新增供应商")
    public AjaxResult addSuppliers(@RequestBody Suppliers suppliers) {
        return AjaxResult.success(service.insertSuppliers(suppliers));
    }
    @PutMapping("/UpdateSuppliers")
    @ApiOperation(value = "修改供应商类别")
    public AjaxResult UpdateSuppliers(@RequestBody Suppliers suppliers){
        return AjaxResult.success(service.updateSuppliers(suppliers));
    }
//    @DeleteMapping("/DeleteSuppliers")
//    @ApiOperation(value = "删除供应商")
//    public AjaxResult DeleteSuppliers(int id) {
//        return AjaxResult.success(service.deleteSuppliersByID(id));
//    }
}
